package ls.jpa.chapterA.expressions;

import com.mysema.query.types.expr.BooleanExpression;
import ls.jpa.chapterA.domain.QCustomer;

import java.util.Calendar;
import java.util.Date;

/**
 * @author Barudisshu
 */
public class CustomerExpressions {

    public static BooleanExpression hasBirthday() {
        Date today = new Date();
        return QCustomer.customer.birthday.eq(today);
    }

    public static BooleanExpression isLongTermCustomer() {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.YEAR, -2);
        return QCustomer.customer.createdAt.lt(calendar.getTime());
    }
}